package com.gandong8.hbase.web.controller;

import com.gandong8.hbase.tool.service.HbaseServiceInter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;


@Slf4j
@Controller
public class IndexController{

    @Autowired
    private HbaseServiceInter hbaseServiceInter;

    @RequestMapping(value = { "", "/" })
    @ResponseBody
    public ModelAndView index() {
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("pageTitle", "HbaseAdmin");
        modelAndView.addObject("cluster", hbaseServiceInter.getClusterInfo());
        modelAndView.setViewName("index");
        return modelAndView;
    }


    @RequestMapping(value = "/404")
    @ResponseBody
    public ModelAndView notFound() {
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("pageTitle", "404");
        modelAndView.setViewName("common/404");
        return modelAndView;
    }

    @RequestMapping(value = "/err")
    @ResponseBody
    public ModelAndView err() {
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("pageTitle", "error");
        modelAndView.addObject("errorMsg", "系统异常");
        modelAndView.setViewName("common/error");
        return modelAndView;
    }


}
